﻿using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;

namespace ConfigurationDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            IConfigurationBuilder builder = new ConfigurationBuilder();
            builder.AddInMemoryCollection(new Dictionary<string, string>()
            {
                {"key1","value1" },
                {"key2","value2" },
                {"section1:key4","value4" },
                {"section2:key5","value5" },
                {"section2:key6","value6" },
                {"section2:section3:key7","value7"}
            });

            IConfigurationRoot configurationRoot = builder.Build();

            Console.WriteLine(configurationRoot["key1"]);
            Console.WriteLine(configurationRoot["key2"]);

            IConfigurationSection section = configurationRoot.GetSection("section1");
            Console.WriteLine($"Key4:{section["key4"]}");
            Console.WriteLine($"Key5:{section["key5"]}");

            IConfigurationSection section2 = configurationRoot.GetSection("section2");
            Console.WriteLine($"Key5_v2:{section2["key5"]}");

            var section3=section2.GetSection("section3");
            Console.WriteLine($"key7:{section3["key7"]}");

        }
    }
}
